<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%@include file="/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html >
<fmt:bundle basename="res">
<head>
    <meta charset="utf-8">
    <title><fmt:message key='ttbl' /></title>
    <jsp:include page="/WEB-INF/commons/commons-header.jsp" flush="true"/>
    <style>
        html {background:#fff;}
    </style>
</head>

<body >
<div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">

    <form:form commandName="user" method="${_method }" class="layui-form">
        <input type="hidden" name="_method" value="${_method }"/>

        <div class="layui-form-item">
            <label class="layui-form-label"><fmt:message key='zhanghao' /></label>
            <div class="layui-input-inline">
                <form:input path="username" class="layui-input"/>
                <input type="hidden" id="hiddenId" value="0"/>
            </div>
        </div>

        <c:if test="${_method eq 'POST'}">

            <div class="layui-form-item">
                <label class="layui-form-label"><fmt:message key='mm' /></label>
                <div class="layui-input-inline">
                    <form:password path="password" class="layui-input" placeholder="<fmt:message key='mm' />"/>
                </div>
            </div>

        </c:if>

        <div class="layui-form-item">
            <label class="layui-form-label"><fmt:message key='xm' /></label>
            <div class="layui-input-inline">
                <form:input path="realName" class="layui-input"/>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><fmt:message key='jslb' /></label>
            <div class="layui-input-inline">
                <c:forEach items="${roles}" var="role">
                    <input type="radio" name="role.id" value="${role.id}" title="${role.showName}" <c:if test="${role.id  eq user.role.id}">checked</c:if>>
                </c:forEach>
            </div>
        </div>

        <div class="layui-input-block">
            <div style="display: none"><input type="button" value="<fmt:message key='bc' />" class="layui-btn" id="submit"></div>
        </div>

    </form:form>
</div>

<script>
    $(function () {
        $("#submit").click(function () {

            $("form").ajaxSubmit({
                success: function (result) {
                    if (result.status) {
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                        parent.$("#search").click();
                    } else {
                        alert(result.message);
                    }
                }
            });
        });
    });
</script>
</body>
</fmt:bundle>
</html>